import React from 'react';
import { history } from 'umi';
import SelfHead from 'components/common/selfHead';
import IMG from 'static/icon.png';
import NewsDic from 'dic/news.js';
import './index.less';

export default function News() {
  const { type } = history.location.query;
  function toDeail(item) {
    history.push({
      pathname: '/news/detail',
      query: { id: item.id },
    });
  }
  return (
    <div className="news">
      <SelfHead title={NewsDic[type].title} />
      <div className="content">
        {NewsDic[type].list.map((item, index) => {
          return (
            <div className="item" key={item.id} onClick={() => toDeail(item)}>
              <div className="img">
                <img src={IMG} alt="" />
              </div>
              <div className="info">
                <p>{item.title}</p>
                <p>{item.time}</p>
              </div>
            </div>
          );
        })}
      </div>
    </div>
  );
}
